Q = require 'q'
fs= require 'fs'

readFile=(file,encoding)->
  deferred = Q.defer()
  fs.readFile file,encoding,(err,data)->
    if err
      deferred.reject(err)
    else
      deferred.resolve(data)
   deferred.promise

a='a'

de=Q.defer()
de.reject 'reject'
func1=()->
  console.log 'fnc1'
func2=()->
  console.log 'func2'

readFile '../file/input.txt','utf-8'
  .then (data)->
    console.log 'file data:',data
    return de
  .then func1,func2
  .catch (err)->
    console.error 'error is :',err